<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/3/19
 * Time: 21:45
 */

namespace Admin\Controller;

class PhotoController extends BaseController
{

    public function photo_list()
    {
        $maps['a.state'] = array('IN',array('0','3'));
        $list = M('photo')->alias('a')
            ->field('a.*,b.nickname')
            ->join('left join t_users b on a.uid = b.id')
            ->order(array('add_time'=>'desc'))
            ->where($maps)
            ->select();
        $this->assign('list',$list);
        $this->display();
    }

    public function updatePhotoState()
    {
        $id = I('id');
        $state = I('state');

        $res = M('photo')->where(array('id'=>$id))->data(array('state'=>$state))->save();
        if ($res) {
            echo "<script>alert('操作成功');location.replace(document.referrer);</script>";
        } else {
            echo "<script>alert('操作失败');location.replace(document.referrer);</script>";
        }
    }

}